#include <asmutils.h>

/* Sends a byte (or word or dword) on a I/O location.
   Traditionnal names are outb, outw and outl respectively.
   The "a" modifier enforce value to be placed in eax register
   before the asm command is issued and "Nd" allows for one-byte
   constant values to be assembled as constants and use edx register
   for other cases. */
__inline__ void outb(_u16 port, _u8 val)
{
    asm volatile("outb %0,%1"::"a"(val), "Nd" (port));
}

__inline__ _u8 inb(_u16 port)
{
    _u8 ret;
    asm volatile("inb %1,%0":"=a"(ret):"Nd"(port));
    return ret;
}

__inline__ void io_wait(void)
{
    asm volatile("outb %%al, $0x80" : : "a"(0));
    // port 0x80 is used for 'checkpoints' during POST.
}

//static __inline__ void io_wait(void)
//{
//    asm volatile("jmp 1f;1:jmp 1f;1:");
//}
